package com.yoki.cloud.common.code.generator.impl;

import com.yoki.cloud.common.code.generator.AbstractCodeGenerator;
import freemarker.template.Configuration;

import java.io.*;
import java.util.*;

/**
 * @author kissy
 * @Description: 后端代码生成器
 * @date 2017/10/24 下午4:38
 */
public class ReactCodeGenerator extends AbstractCodeGenerator {

    /**
     * 保存文件路径
     */
    private static final String SAVE_PATH_PRE = "C:\\Users\\Sky\\Desktop\\code\\vp-html\\";
    /**
     * 基础包名
     */
    private static final String BASE_PACKAGE = "org.yoki.edu.video";
    /**
     * 模块名，分包用
     */
//    private static final String MODULE_NAME = "vp";

    @Override
    public String getBasePackage() {
        return BASE_PACKAGE;
    }

//    @Override
//    public String getModuleName() {
//        return MODULE_NAME;
//    }

    @Override
    public String getSavePathPre() {
        return SAVE_PATH_PRE;
    }

    @Override
    public String getFtlRelativePath() {
        return "react";
    }

    public static void main(String[] args) throws Exception {
        ReactCodeGenerator generator = new ReactCodeGenerator();
        generator.generate();
    }

    @Override
    protected void genFiles(Map beanMap, Configuration cfg) throws IOException {
        genFile(beanMap, cfg,  "model.ftl", ".js");
        genFile(beanMap, cfg,  "add.ftl", "CreateForm.js");
        genFile(beanMap, cfg,  "edit.ftl", "UpdateForm.js");
        genFile(beanMap, cfg,  "list.ftl", "List.js");
        genFile(beanMap, cfg,  "pages.ftl", "Page.js");
        genFile(beanMap, cfg,  "service.ftl", "Service.js");
    }

}
